﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace ClientSocketTest
{
    public class InformationControl
    {
        public enum MsgType { Incoming, Outgoing, Normal, Warning, Error, Test };
        // Various colors for logging info
        private static readonly Color[] MsgTypeColor = { Color.Blue, Color.Green, Color.Black, Color.Orange, Color.Red, Color.Pink };
        public static void Messages(RichTextBox richTextBox, MsgType type, string msg)
        {
            //richTextBox.Invoke(new EventHandler(delegate
            //{
            //    richTextBox.SelectedText = string.Empty;
            //    richTextBox.SelectionFont = new Font(richTextBox.SelectionFont, FontStyle.Bold);
            //    richTextBox.SelectionColor = MsgTypeColor[(int)type];
            //    richTextBox.AppendText(msg);
            //    richTextBox.ScrollToCaret();
            //}));
            richTextBox.Invoke((Action)delegate()
            {
                richTextBox.SelectedText = string.Empty;
                richTextBox.SelectionFont = new Font(richTextBox.SelectionFont, FontStyle.Bold);
                richTextBox.SelectionColor = MsgTypeColor[(int)type];
                richTextBox.AppendText(msg);
                richTextBox.ScrollToCaret();
            });

        }
        public static void MsgClear(RichTextBox richTextBox)
        {
            //richTextBox.Invoke(new EventHandler(delegate
            //{
            //    richTextBox.Clear();
            //}));          
            richTextBox.Invoke((Action)delegate()
            {
                richTextBox.Clear();
            });
        }
    }//public class InformationControl
}//namespace ClientSocketTest
